#include <stdio.h>
#include <signal.h>
#include <unistd.h>

volatile sig_atomic_t* shared_counter;

void handler(int sig)
{
    (*shared_counter)++;
}

/**
 * 
*/
int main(int argc, char const *argv[])
{
    sig_atomic_t counter = 0;
    shared_counter = &counter;

    signal(SIGUSR1, handler);

    while (1)
    {
        sleep(1);
        printf("counter: %d\n", *shared_counter);
    }
    
    return 0;
}